/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author has
 */
@Entity
@Table(name = "user", catalog = "onsale", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findByIdUser", query = "SELECT u FROM User u WHERE u.idUser = :idUser"),
    @NamedQuery(name = "User.findByNamaDepan", query = "SELECT u FROM User u WHERE u.namaDepan = :namaDepan"),
    @NamedQuery(name = "User.findByNamaBelakang", query = "SELECT u FROM User u WHERE u.namaBelakang = :namaBelakang"),
    @NamedQuery(name = "User.findByAsal", query = "SELECT u FROM User u WHERE u.asal = :asal"),
    @NamedQuery(name = "User.findByNoTelpon", query = "SELECT u FROM User u WHERE u.noTelpon = :noTelpon"),
    @NamedQuery(name = "User.findByEmail", query = "SELECT u FROM User u WHERE u.email = :email"),
    @NamedQuery(name = "User.findByUsername", query = "SELECT u FROM User u WHERE u.username = :username"),
    @NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"),
    @NamedQuery(name = "User.findByConfirmPassword", query = "SELECT u FROM User u WHERE u.confirmPassword = :confirmPassword"),
    @NamedQuery(name = "User.findByAdminStat", query = "SELECT u FROM User u WHERE u.adminStat = :adminStat")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idUser", nullable = false)
    private Integer idUser;
    @Basic(optional = false)
    @Column(name = "namaDepan", nullable = false, length = 25)
    private String namaDepan;
    @Basic(optional = false)
    @Column(name = "namaBelakang", nullable = false, length = 25)
    private String namaBelakang;
    @Basic(optional = false)
    @Column(name = "asal", nullable = false, length = 25)
    private String asal;
    @Basic(optional = false)
    @Column(name = "noTelpon", nullable = false, length = 25)
    private String noTelpon;
    @Basic(optional = false)
    @Column(name = "email", nullable = false, length = 25)
    private String email;
    @Basic(optional = false)
    @Column(name = "username", nullable = false, length = 25)
    private String username;
    @Basic(optional = false)
    @Column(name = "password", nullable = false, length = 25)
    private String password;
    @Basic(optional = false)
    @Column(name = "confirmPassword", nullable = false, length = 25)
    private String confirmPassword;
    @Basic(optional = false)
    @Column(name = "adminStat", nullable = false)
    private boolean adminStat;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idUser", fetch = FetchType.LAZY)
    private Collection<Barang> barangCollection;
    @OneToMany(mappedBy = "idUser", fetch = FetchType.LAZY)
    private Collection<Pilihstatus> pilihstatusCollection;

    public User() {
    }

    public User(Integer idUser) {
        this.idUser = idUser;
    }

    public User(Integer idUser, String namaDepan, String namaBelakang, String asal, String noTelpon, String email, String username, String password, String confirmPassword, boolean adminStat) {
        this.idUser = idUser;
        this.namaDepan = namaDepan;
        this.namaBelakang = namaBelakang;
        this.asal = asal;
        this.noTelpon = noTelpon;
        this.email = email;
        this.username = username;
        this.password = password;
        this.confirmPassword = confirmPassword;
        this.adminStat = adminStat;
    }

    public Integer getIdUser() {
        return idUser;
    }

    public void setIdUser(Integer idUser) {
        this.idUser = idUser;
    }

    public String getNamaDepan() {
        return namaDepan;
    }

    public void setNamaDepan(String namaDepan) {
        this.namaDepan = namaDepan;
    }

    public String getNamaBelakang() {
        return namaBelakang;
    }

    public void setNamaBelakang(String namaBelakang) {
        this.namaBelakang = namaBelakang;
    }

    public String getAsal() {
        return asal;
    }

    public void setAsal(String asal) {
        this.asal = asal;
    }

    public String getNoTelpon() {
        return noTelpon;
    }

    public void setNoTelpon(String noTelpon) {
        this.noTelpon = noTelpon;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public boolean getAdminStat() {
        return adminStat;
    }

    public void setAdminStat(boolean adminStat) {
        this.adminStat = adminStat;
    }

    @XmlTransient
    public Collection<Barang> getBarangCollection() {
        return barangCollection;
    }

    public void setBarangCollection(Collection<Barang> barangCollection) {
        this.barangCollection = barangCollection;
    }

    @XmlTransient
    public Collection<Pilihstatus> getPilihstatusCollection() {
        return pilihstatusCollection;
    }

    public void setPilihstatusCollection(Collection<Pilihstatus> pilihstatusCollection) {
        this.pilihstatusCollection = pilihstatusCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUser != null ? idUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.idUser == null && other.idUser != null) || (this.idUser != null && !this.idUser.equals(other.idUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.User[ idUser=" + idUser + " ]";
    }
    
}
